﻿using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace Transliterator
{
    public class Procesor
    {
        public Procesor(string root)
        {
            Root = new DirectoryInfo(root);
        }

        private DirectoryInfo Root { get; set; }

        public List<FileInfo> GetAllLocalizationFiles()
        {
            IEnumerable<FileInfo> ret = from f in Root.GetFiles("*.po", SearchOption.AllDirectories)
                                        where f.FullName.Contains("sr-Latn-RS")
                                        select f;

            return ret.ToList();
        }

        public void Transliterate()
        {
            Parallel.ForEach(GetAllLocalizationFiles(),
                             f => new PoFileProcesor(new Transliterator(), f.FullName).Transliterate());
        }
    }
}